package com.smartmap.chat;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;

public class BaseData {

	private static Gson gson;
	private static List<UserGroup> users;

	static {
		gson = new Gson();
		users = new ArrayList<UserGroup>();
	}

	public static void initDate() {
		AsyncHttpClient client = new AsyncHttpClient();
		client.get("http://172.31.113.147:8080/smartmap/talk/list",
				new AsyncHttpResponseHandler() {
					@Override
					public void onSuccess(String response) {
						List<UserInformation> userInformations = gson.fromJson(
								response,
								new TypeToken<List<UserInformation>>() {
								}.getType());
						UserGroup group = new UserGroup("我的好友", userInformations.size());
						group.setUserList(userInformations);
						users.add(group);
					}
				});

	}

	public static List<UserGroup> getUsers() {
		return users;
	}

}
